# coding:utf-8
from flask import Blueprint
# 注册蓝图
from flask import current_app
from flask import make_response
from flask.ext.wtf.csrf import generate_csrf

web = Blueprint('web', __name__)


# print(12321321)
@web.route('/<re(".*"):filename>')
def static_html(filename):
    # print(5555555555)
    print(filename)
    # 如果是 / 那么重新给他赋值为index.html,
    if not filename:
        filename = '/index.html'
    if filename != 'favicon.ico':
        filename = 'html/' + filename
    print filename

    response = make_response(current_app.send_static_file(filename))
    # 在此设置cookie中的csrf_token
    response.set_cookie('csrf_token', generate_csrf())
    return response
    # return 'index'
